package com.goodfather.textbook.youdao.pad.bean;

import android.os.Parcel;
import android.os.Parcelable;

import java.util.ArrayList;

/**
 * 课程
 */
public class Lessons implements Parcelable {

    public String bookId;
    public String publishingId;
    public String lessonId;
    public String unitName;
    public String lessonName;
    public boolean isFree;
    public int kindId;
    public int beginPage;
    public int beginPageNum;
    public int endPageNum;
    public String audioUrl;
    public String videoUrl;
    public String imageUrl;

    public int startIndex;//当前课程第一页在所有页数的index
    public int endIndex;//当前课程最后一页在所有页数的index
    public ArrayList<Pages> pages;
    public ArrayList<Sentence> sentences;


    protected Lessons(Parcel in) {
        bookId = in.readString();
        publishingId = in.readString();
        lessonId = in.readString();
        unitName = in.readString();
        lessonName = in.readString();
        isFree = in.readByte() != 0;
        kindId = in.readInt();
        beginPage = in.readInt();
        beginPageNum = in.readInt();
        endPageNum = in.readInt();
        audioUrl = in.readString();
        videoUrl = in.readString();
        imageUrl = in.readString();
        startIndex = in.readInt();
        endIndex = in.readInt();
        pages = in.createTypedArrayList(Pages.CREATOR);
        sentences = in.createTypedArrayList(Sentence.CREATOR);
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(bookId);
        dest.writeString(publishingId);
        dest.writeString(lessonId);
        dest.writeString(unitName);
        dest.writeString(lessonName);
        dest.writeByte((byte) (isFree ? 1 : 0));
        dest.writeInt(kindId);
        dest.writeInt(beginPage);
        dest.writeInt(beginPageNum);
        dest.writeInt(endPageNum);
        dest.writeString(audioUrl);
        dest.writeString(videoUrl);
        dest.writeString(imageUrl);
        dest.writeInt(startIndex);
        dest.writeInt(endIndex);
        dest.writeTypedList(pages);
        dest.writeTypedList(sentences);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final Creator<Lessons> CREATOR = new Creator<Lessons>() {
        @Override
        public Lessons createFromParcel(Parcel in) {
            return new Lessons(in);
        }

        @Override
        public Lessons[] newArray(int size) {
            return new Lessons[size];
        }
    };
}